import api from '../../api';

export default {
  namespace: 'priceCalculation',
  state: {
    priceCalculation: {},
  },
  effects: {
    //债券价格试算
    *priceCalculation({ payload, callback }, { call, put, select }) {
      const res = yield call(api.priceCalculation, payload);
      if (res && res.code == 0) {
        yield put({
          type: 'setState',
          payload: {
            priceCalculation: res.data,
          },
        });
      }

      callback(res.data);
    },
  },

  reducers: {
    setState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
